define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'honorscorelog/index',
                    table: 'c_honorscore_log',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search: false,
                columns: [
                    [
                     	{field: 'nickname', title: '成员昵称', operate: false},
                        {field: 'uid', title:'成员ID', operate: false},
                        {field: 'currentscore', title:'成员荣誉分', operate: false},
                        {field: 'honorscore', title:'赠送荣誉分', operate: false},
                        {field: 'restscore', title:'荣誉分余额', operate: false},
                        {field: 'type', title: '赠送方式', operate: false},
                        {field: 'createtime', title:'赠送时间', formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});